package com.guigu.www.controller.yinBo;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.guigu.www.dao.bean.TMemberExamination;
import com.guigu.www.dao.bean.TSetmeal;
import com.guigu.www.service.TSetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 套餐表 前端控制器
 * </p>
 *
 * @author WangChenZhen
 * @since 2021-06-16
 */
@CrossOrigin
@RestController
@RequestMapping("/tSetmeal")
public class TSetmealController {

    @Autowired
    TSetmealService tSetmealService;

    /*查询所有的套餐信息*/
    @GetMapping("")
    public List<TSetmeal> query(){
        Wrapper<TSetmeal> wrapper = new EntityWrapper<TSetmeal>();
        wrapper.eq("state",'0');
        List<TSetmeal> tSetmeals = tSetmealService.selectList(wrapper);
        return tSetmeals;
    }
    /*按性别查询套餐信息*/
    @GetMapping("/{sex}")
    public List<TSetmeal> querySex(@PathVariable("sex") String sex){
        Wrapper<TSetmeal> wrapper = new EntityWrapper<TSetmeal>();
        wrapper.eq("sex",sex);
        List<TSetmeal> tSetmeals = tSetmealService.selectList(wrapper);
        return tSetmeals;
    }
    @PostMapping("namelist")
    public List<String> queryId(@RequestBody List<TMemberExamination> lista){
        List<String> taocanmingzi = new ArrayList<String>();
        System.out.println("lista"+lista);
        for (TMemberExamination x:lista) {
            EntityWrapper<TSetmeal> wrapper = new EntityWrapper<TSetmeal>();
            wrapper.eq("id",x.getTSetmealId());
            System.out.println("tsetmid:"+x.getTSetmealId());
            TSetmeal tSetmeal = tSetmealService.selectOne(wrapper);
            System.out.println("asdad:"+tSetmeal);
            taocanmingzi.add(tSetmeal.getName());
        }
        return taocanmingzi;
    }
}

